package seabattle.ship;

import seabattle.field.BattleField;

public class RandomShipGenerator implements ShipGenerator {

    public Ship generate(int shipSize) {
        int x, y;
        Direction direction = Direction.getRandom();
        if (direction.isVertical()) {
            x = (int) (Math.random() * BattleField.SIZE);
            y = (int) (Math.random() * (BattleField.SIZE - shipSize + 1));
        } else {
            x = (int) (Math.random() * (BattleField.SIZE - shipSize + 1));
            y = (int) (Math.random() * BattleField.SIZE);
        }
        return new Ship(new Coordinates(x, y), shipSize, direction);
    }

}
